const {
  defineConfig
} = require('@vue/cli-service')
// const bundleAnalyzer = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
module.exports = defineConfig({
  publicPath: process.env.NODE_ENV === "production" ? "/market" : "/",

  transpileDependencies: true,
  lintOnSave: false, //关闭eslint语法检测
  devServer: {
    host: 'localhost',
    port: 8066,
    hot: true,
    https: false, 
    proxy: { //配置多个代理
      "/testIp": {
          target: "http://197.0.0.1:8088",
          changeOrigin: true,
          ws: true,//websocket支持
          secure: false,
          pathRewrite: {
              "^/testIp": "/"
          }
      },
      "/elseIp": {
          target: "http://197.0.0.2:8088",
          changeOrigin: true,
          //ws: true,//websocket支持
          secure: false,
          pathRewrite: {
              "^/elseIp": "/"
          }
      },
      [process.env.VUE_APP_BASE_API]: {
        // target: `http://zhinong.lecyon.com:8066`,
        target: `http://localhost:8066`,
        // target: `http://crm.yaomaiqi.com:8081/ruoyi-admin/`, // 服务端地址
        changeOrigin: true,
        pathRewrite: {
          ["^" + process.env.VUE_APP_BASE_API]: "",
        },
      },
  }
  },
  chainWebpack: (config) => {
    const oneOfsMap = config.module.rule("scss").oneOfs.store;
    oneOfsMap.forEach((item) => {
      item
        .use("sass-resources-loader")
        .loader("sass-resources-loader")
        .options({
          // 全局变量文件路径，只有一个时可将数组省去
          resources: ["./src/assets/scss/base.scss"],
        })
        .end();
    });
  },
  configureWebpack:config=>{
    config.plugins.push(
      // new bundleAnalyzer()
    )
  },
  css: {
    loaderOptions: {
      less: {
        // 若 less-loader 版本小于 6.0，请移除 lessOptions 这一级，直接配置选项。
        lessOptions: {
          modifyVars: {
            // 直接覆盖变量
            '@font-size-lg': '28px',
            '@font-size-md': '26px',
            '@picker-toolbar-height': '88px',
            '@picker-title-line-height': '88px',
            '@toast-default-width': '188px',
            '@toast-default-min-height': '188px',
            '@calendar-confirm-button-height': '56px',
            '@calendar-weekdays-height': '50px',
            '@calendar-weekdays-font-size':'28px'
          },
        },
      },
    },
  },
})